<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class About_model extends CI_Model {
    
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
        $this->load->database();
    }
    
    
    /**
     * list list about by typeId
     */
    function getByTypeId($typeId){
        $mysql = "SELECT * FROM service WHERE type=$typeId";
        $data = $this->db->query($mysql);
        return $data->result_array();
    }
    
    function insert($array)
    {
        $data = array(
            'name_vn' => $array['name_vn'],
            'name_en' => $array['name_en'],
            'name_jp' => $array['name_jp'],
            
            'content_vn' => $array['content_vn'],
            'content_en' => $array['content_en'],
            'content_jp' => $array['content_jp'],
            
            'summary_vn' => $array['summary_vn'],
            'summary_en' => $array['summary_en'],
            'summary_jp' => $array['summary_jp'],

            'type' => $array['type'],
        );
        $this->db->insert('service', $data);
        $id = $this->db->insert_id();
        return $id;
    }
    /**
    * get category by product_id
    * 
    * @param mixed $id
    */
    function getByAboutId($id)
    {
        $mysql = "SELECT * FROM service WHERE id = $id";
        $data = $this->db->query($mysql);
        return $data->row_array();
    }

    /** 
    * update product by id
    * 
    */
    function update($array)
    {
        $data = array(
            'id' =>$array['id'],
            'name_vn' => $array['name_vn'],
            'name_en' => $array['name_en'],
            'name_jp' => $array['name_jp'],
            
            'content_vn' => $array['content_vn'],
            'content_en' => $array['content_en'],
            'content_jp' => $array['content_jp'],
            
            'summary_vn' => $array['summary_vn'],
            'summary_en' => $array['summary_en'],
            'summary_jp' => $array['summary_jp'],

        );
        $this->db->where('id', $data['id']);
        $this->db->update('service', $data);
    }
    /**
    * delete productId
    * 
    * @param mixed $id
    */
    function delete($id) {
        $this->db->where('id', $id);
        $this->db->delete('service');
    }

}
?>
